#ifndef __EPOLLH__
#define __EPOLLH__

#include <vector>
#include <sys/epoll.h>
#include <memory>
#include <unordered_map>
#include "Channel.h"

using std::vector;
using std::shared_ptr;
using std::unordered_map;

class Epoll
{
public:
    Epoll();
    void loop();
    void epollAdd(int fd, void *pconn, shared_ptr<Channel> pchannel);
    void epollDel(int fd);
    void epollWrite(int fd, void *ud, bool enable);

    unordered_map<int, shared_ptr<Channel>> channels_;

private:
    static int createEpollfd(); 
  
private:
    int epollfd_;

    static const int maxcount = 64;
    struct epoll_event evs[maxcount];
};

#endif
